                <?php slot('title') ?>
                    <?php echo sprintf('Zestawienie') ?>
                <?php end_slot(); ?>
                <?php 
                    slot('bodyId');
                        echo 'action';
                    end_slot(); 
                    slot('zestawienieActive');end_slot();
                ?>
                <?php use_helper('Date', 'Text') ?>
                <?php 
                    if ($sf_user->getGuardUser()->hasPermission(sfConfig::get('app_terapeuta_permission_name'))):
                        include_component('zestawienie', 'menuTerapeuta');
                    ?>
                        <div class="grid_10">
                            <div class="dashboard">   
                                <h3>Ostatnio aktywni podopieczni</h3></li>
                                <div class="clear"></div>                                
                                <table class="dash">
                                    <tbody>
                                        <tr>
                                            <th>&nbsp;</th>
                                            <th>Podopieczny</th>
                                            <th>Czas gry</th>
                                            <th>Wynik</th>
                                            <th>Kiedy</th>
                                            <th>&nbsp;</th>
                                        </tr>   
                                        <?php 
                                            foreach ($terapeuta_pager as $i => $contact): 
                                                $_user = $contact->getTo();
                                                 if($contact->type->id == 3):                                             
                                            ?>
                                                <tr class="<?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
                                                    <td>
                                                         <a href="<?php echo url_for('wyniki/wynikipacjentlista?personid=' . $_user->id ) ?>">
                                                             <?php if (file_exists('./uploads/sf_social_pics/'.$_user->Profile->picture) && $_user->Profile->picture !=null) { ?>
                                                                <img alt="" title="" class="profileImageMini" src="/uploads/sf_social_pics/<?php echo $_user->Profile->picture ?>" /> 
                                                             <?php } else { ?>
                                                                <img alt="" title="" class="profileImageMini" src="/uploads/sf_social_pics/person-blank.gif" /> 
                                                             <?php } ?>
                                                         </a>
                                                    </td>
                                                    <td>
                                                        <a href="<?php echo url_for('wyniki/wynikipacjentlista?personid=' . $_user->id ) ?>"><?php echo $_user->username ?></a>
                                                    </td>
                                                    <td>
                                                    </td>
                                                    <td>

                                                    </td>
                                                    <td>

                                                    </td>
                                                    <td>
                                                        <a href="<?php echo url_for('wyniki/wynikipacjentlista?personid=' . $_user->id ) ?>">więcej</a>
                                                    </td>
                                                </tr>
                                            <?php                                             
                                                 endif;
                                            endforeach; ?>  
                                    </tbody>                        
                                </table>
                                <div class="twoiZnajomi">
                                    <h3>Twoje kontakty</h3><?php echo link_to(__('wszyscy', null, 'sfSocial'), '@sf_social_contact_list', array('class' => 'small head')) ?>
                                    <div class="clear"></div>
                                    <ul><?php 
                                        foreach ($pager as $contact): 
                                            $_user = $contact->getTo() ?>
                                            <li>                                               
                                                     <a href="<?php echo url_for('@sf_social_user?username=' . $_user) ?>">
                                                         <?php if (file_exists('./uploads/sf_social_pics/'.$_user->Profile->picture) && $_user->Profile->picture !=null) { ?>
                                                            <img alt="" title="" src="/uploads/sf_social_pics/<?php echo $_user->Profile->picture ?>" /> 
                                                         <?php } else { ?>
                                                            <img alt="" title="" src="/uploads/sf_social_pics/person-blank.gif" /> 
                                                         <?php } ?>
                                                     </a>
                                                
                                                <br/>
                                                <?php echo link_to($_user, 'sf_social_user', $_user) ?>     <br /><p class="rola"><?php echo $contact->type->name  ?></p>                      
                                            </li>
                                        <?php endforeach ?>
                                    </ul>
                                </div>
                                <div class="rankingi">
                                    <h3>Najaktywniejsi</h3><?php echo link_to(__('więcej', null, 'serwis'), '@statystyki', array('class' => 'small head')) ?>
                                    <div class="clear"></div>
                                    <?php foreach ($game_data as $game): endforeach; ?>
                                    <img src="/uploads/games/<?php echo $game->img; ?>" class="graMini"/>
                                    <p>Gra: <a href="#"><?php echo $game->name; ?></a></p>
                                    <ul>                                
                                        <?php 
                                        $i = 0;
                                        $counter = 0;
                                        $parity = 'odd';
                                        foreach ($global_game_results as $global_game_result): 
                                            $counter++;
                                            $i++;
                                            if ($counter % 2) {
                                                $parity = 'odd';
                                            } else {
                                                $parity = 'even';
                                            } ?>
                                            <li class="<?php echo $parity.' '; if($global_game_result->getUser()->getId() == $user->getId()) {echo 'thatsMe';} ?>">
                                                <ul class="result">
                                                    <li><span><?php echo $global_game_result->max ?>pkt</span><?php echo $i; ?>. <p><?php echo $global_game_result->getUser()->getUsername() ?></p></li>
                                                </ul>
                                            </li>
                                        <?php endforeach; ?>                        
                                    </ul>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                    <?php
                    else:    // Ponizej zwykly panel (panel gracza)
                        include_component('zestawienie', 'menu'); 
                    ?>
                        <div class="grid_10">
                            <div class="dashboard">   
                                <h3>Ostatnie gry</h3><?php echo link_to(__('moje wyniki', null, 'serwis'), '@wyniki', array('class' => 'small head')) ?></li>
                                <div class="clear"></div>
                                <table class="dash">
                                    <tbody>
                                        <tr>
                                            <th>&nbsp;</th>
                                            <th class="name">Nazwa gry</th>
                                            <th>Czas gry</th>
                                            <th>Ilość powtórzeń</th>
                                            <th>Średni wynik</th>
                                            <th>Kiedy</th>
                                            <th>&nbsp;</th>
                                        </tr><?php 
                                        $counter = 0;
                                        $parity = 'odd';
                                        foreach ($game_results as $game_result): 
                                            $counter++;
                                            if ($counter % 2) {
                                                $parity = 'odd';
                                            } else {
                                                $parity = 'even';
                                            } ?>
                                            <tr class="<?php echo $parity ?>">
                                                <td>
                                                    <a href="<?php echo url_for('gry/show?id='.$game_result->getGamesId()); ?>">
                                                        <img src="/uploads/games/<?php echo $game_result->getGames()->getImg();?>" class="graMini"/>
                                                    </a>
                                                </td>
                                                <td class="name">
                                                    <a href="<?php echo url_for('gry/show?id='.$game_result->getGamesId()); ?>"><?php echo truncate_text($game_result->games->name, 30) ?></a>
                                                </td>
                                                <td>
                                                    <?php 
                                                    include_component('zestawienie', 'getAllDatesInARow', array('gameid' => $game_result->games_id, 'rozgrywka_id' => $game_result->rozgrywka_id));
                                                    //
                                                    ////echo $game_result->ile_czasu; ?>    
                                                </td>
                                                <td>
                                                    <?php echo $game_result->ilosc ; ?>
                                                </td>
                                                <td>
                                                    <?php echo round($game_result->avg_pkt, 2) ?>
                                                </td>
                                                <td>
                                                    <?php echo $game_result->ile_dni.' dni temu';//time_ago_in_words($game_result->getStartDate()) ?>
                                                </td>
                                                <td>

                                                </td>
                                            </tr>
                                        <?php endforeach; ?>  
                                    </tbody>                        
                                </table>
                                <div class="twoiZnajomi">
                                    <h3>Twoi znajomi</h3><?php echo link_to(__('wszyscy', null, 'sfSocial'), '@sf_social_contact_list', array('class' => 'small head')) ?>
                                    <div class="clear"></div>
                                    <ul><?php 
                                        foreach ($pager as $contact): 
                                            $_user = $contact->getTo() ?>
                                            <li>
                                                <?php //echo link_to(image_tag($_user->getThumb(), 'alt=' . $_user . ' title=' . $_user . ' class=left'), 'sf_social_user', $_user) ?>

                                                     <a href="<?php url_for('@sf_social_user?username=' . $_user) ?>"> <img alt="" title="" class="" width="31" height="31" src="/uploads/sf_social_pics/<?php 

                                                    if (file_exists('./uploads/sf_social_pics/'.$_user->Profile->picture)) {
                                                        echo $_user->Profile->picture;

                                                    } else {
                                                        echo 'blank.jpg';
                                                    }

                                                    ?>"></a>



                                                <br/>
                                                <?php echo link_to($_user, 'sf_social_user', $_user) ?>     <br /><p class="rola"><?php echo $contact->type->name  ?></p>                      
                                            </li>
                                        <?php endforeach ?>
                                    </ul>
                                </div>
                                <div class="rankingi">
                                    <h3>Rankingi</h3><?php echo link_to(__('więcej rankingów', null, 'serwis'), '@statystyki', array('class' => 'small head')) ?>
                                    <div class="clear"></div>
                                    <?php foreach ($game_data as $game): endforeach; ?>
                                    <img src="/uploads/games/<?php echo $game->img; ?>" class="graMini"/>
                                    <p>Gra: <a href="#"><?php echo $game->name; ?></a></p>
                                    <ul>                                
                                        <?php 
                                        $i = 0;
                                        $counter = 0;
                                        $parity = 'odd';
                                        foreach ($global_game_results as $global_game_result): 
                                            $counter++;
                                            $i++;
                                            if ($counter % 2) {
                                                $parity = 'odd';
                                            } else {
                                                $parity = 'even';
                                            } ?>
                                            <li class="<?php echo $parity.' '; if($global_game_result->getUser()->getId() == $user->getId()) {echo 'thatsMe';} ?>">
                                                <ul class="result">
                                                    <li><span><?php echo $global_game_result->max ?>pkt</span><?php echo $i; ?>. <p><?php echo $global_game_result->getUser()->getUsername() ?></p></li>
                                                </ul>
                                            </li>
                                        <?php endforeach; ?>                        
                                    </ul>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                <?php 
                    endif;
                ?>
		<div class="clear"></div>
 